package com.huasan.www.demon.data.service.impl;
import com.huasan.www.demon.util.OnePage;
import com.huasan.www.demon.util.Page;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.huasan.www.demon.data.dao.UserdetailMapper;
import com.huasan.www.demon.data.service.UserdetailService;
import com.huasan.www.demon.pojo.SumDetailStatus;
import com.huasan.www.demon.pojo.Userdetail;
import com.huasan.www.demon.pojo.UserdetailExample;

import java.util.List;

import org.apache.ibatis.annotations.Param;

@Service("userdetailService")
public class UserdetailServiceImpl implements UserdetailService{
	
    @Autowired
    private UserdetailMapper userdetailDao;    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userdetail
     *
     * @mbggenerated Tue Jan 21 00:35:22 CST 2014
     */
    public int countByExample(UserdetailExample example){
      return userdetailDao.countByExample(example);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userdetail
     *
     * @mbggenerated Tue Jan 21 00:35:22 CST 2014
     */
    public int deleteByExample(UserdetailExample example){
      return userdetailDao.deleteByExample(example);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userdetail
     *
     * @mbggenerated Tue Jan 21 00:35:22 CST 2014
     */
    public int deleteByPrimaryKey(Long id){
      return userdetailDao.deleteByPrimaryKey(id);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userdetail
     *
     * @mbggenerated Tue Jan 21 00:35:22 CST 2014
     */
    public int insert(Userdetail record){
      return userdetailDao.insert(record);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userdetail
     *
     * @mbggenerated Tue Jan 21 00:35:22 CST 2014
     */
    public int insertSelective(Userdetail record){
      return userdetailDao.insertSelective(record);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userdetail
     *
     * @mbggenerated Tue Jan 21 00:35:22 CST 2014
     */
    public List<Userdetail> selectByExample(UserdetailExample example){
      return userdetailDao.selectByExample(example);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userdetail
     *
     * @mbggenerated Tue Jan 21 00:35:22 CST 2014
     */
    public Userdetail selectByPrimaryKey(Long id){
      return userdetailDao.selectByPrimaryKey(id);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userdetail
     *
     * @mbggenerated Tue Jan 21 00:35:22 CST 2014
     */
    public int updateByExampleSelective(@Param("record") Userdetail record, @Param("example") UserdetailExample example){
      return userdetailDao.updateByExampleSelective(record,example);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userdetail
     *
     * @mbggenerated Tue Jan 21 00:35:22 CST 2014
     */
    public int updateByExample(@Param("record") Userdetail record, @Param("example") UserdetailExample example){
      return userdetailDao.updateByExample(record,example);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userdetail
     *
     * @mbggenerated Tue Jan 21 00:35:22 CST 2014
     */
    public int updateByPrimaryKeySelective(Userdetail record){
      return userdetailDao.updateByPrimaryKeySelective(record);
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table userdetail
     *
     * @mbggenerated Tue Jan 21 00:35:22 CST 2014
     */
    public int updateByPrimaryKey(Userdetail record){
      return userdetailDao.updateByPrimaryKey(record);
    }
    
    public List<SumDetailStatus> selectGroupByStatusExample(UserdetailExample example){
    	return userdetailDao.selectGroupByStatusExample(example);
    }
    
    public int sumDuraByExample(UserdetailExample example){
    	return userdetailDao.sumDuraByExample(example);
    }

    public OnePage<Userdetail> selectOnePageByExample(UserdetailExample example){
    	int count = userdetailDao.countByExample(example);
    	List<Userdetail> dataList = userdetailDao.selectByExample(example);
    	OnePage<Userdetail> onepage = new OnePage<Userdetail>();
    	onepage.setPage(new Page(example.getLimitStart(), example.getLimitEnd()));
    	onepage.getPage().setCount(count);
    	onepage.setDataList(dataList);
    	return onepage;
    }
}